package org.eminem.spring.cloud.finchley.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.eminem.spring.cloud.finchley.model.User;
import org.eminem.spring.cloud.finchley.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/user")
@Api(tags = "用户接口")
public class UserController {

	@Autowired
	private UserService userService;
	/**
	 * 用于演示Feign的Get请求多参数传递
	 * @param user
	 * @return
	 */
	@PostMapping(value = "/add")
	@ApiOperation(value = "新增用户",notes ="",httpMethod = "POST")
	public String addUser( @RequestBody @ApiParam(name="用户",value="传入json格式",required=true) User user){
		return this.userService.addUser(user);
	}

	/**
	 * 用于演示Feign的Post请求多参数传递
	 * @param user
	 * @return
	 */
	@PostMapping(value = "/update")
	@ApiOperation(value = "修改用户",notes ="",httpMethod = "POST")
	public String updateUser( @RequestBody @ApiParam(name="用户",value="传入json格式",required=true) User user){
		return this.userService.updateUser(user);
	}

}
